//
//  ViewControllerOfLogin.m
//  02-UI
//
//  Created by Snow on 16/7/15.
//  Copyright © 2016年 Snow. All rights reserved.
//

#import "ViewControllerOfLogin.h"
#import "ViewControllerSignIn.h"
#import "ViewControllerOfMiss.h"

@interface ViewControllerOfLogin ()

@end

@implementation ViewControllerOfLogin

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];//添加背景图片
    UIView *viewOfBlack = [[UIView alloc] initWithFrame:self.view.frame];
    viewOfBlack.backgroundColor = [UIColor blackColor];
    viewOfBlack.alpha = 0.7;
    [self.view addSubview:viewOfBlack];
    UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"welcome_2"]];
    [self.view addSubview:imageView];
    imageView.frame = self.view.frame;
    imageView.alpha = 0.7;
    imageView.userInteractionEnabled = YES;
    //添加图标(中心)
    UIImageView *imageOfFlag = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo_lagou"]];
    imageOfFlag.frame = CGRectMake(150, 110, 90, 150);
    [imageView addSubview:imageOfFlag];
    //用户账号密码
    UIView *viewOfUserPassWord = [[UIView alloc] initWithFrame:CGRectMake(10, 300, 355, 81)];
    viewOfUserPassWord.backgroundColor = [UIColor blackColor];
    [imageView addSubview:viewOfUserPassWord];
    viewOfUserPassWord.alpha = 0.7;
    viewOfUserPassWord.layer.masksToBounds = YES;
    viewOfUserPassWord.layer.cornerRadius = 5;
    UITextField *textOfUser = [[UITextField alloc] initWithFrame:CGRectMake(20, 300, 345, 40)];
    textOfUser.placeholder = @"请输入已验证手机号码或邮箱";
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[NSForegroundColorAttributeName] = [UIColor lightGrayColor];
    NSAttributedString *attribute = [[NSAttributedString alloc] initWithString:textOfUser.placeholder attributes:dict];
    [textOfUser setAttributedPlaceholder:attribute];//设置placeholder的字体颜色
    [imageView addSubview:textOfUser];
    UIImageView *image1 = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"icon_username_select"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    image1.frame = CGRectMake(10, 300, 20, 20);
    textOfUser.leftView = image1;
    textOfUser.leftViewMode = UITextFieldViewModeAlways;
    UIView *viewOfLine = [[UIView alloc] initWithFrame:CGRectMake(10, 340, 355, 1)];
    viewOfLine.backgroundColor = [UIColor whiteColor];
    [imageView addSubview:viewOfLine];
    viewOfLine.alpha = 0.3;
    UITextField *textOfPassword = [[UITextField alloc] initWithFrame:CGRectMake(10, 341, 355, 40)];
    textOfPassword.placeholder = @"请输入密码";
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    dic[NSForegroundColorAttributeName] = [UIColor lightGrayColor];
    NSAttributedString *attribute1 = [[NSAttributedString alloc] initWithString:textOfPassword.placeholder attributes:dic];
    [textOfPassword setAttributedPlaceholder:attribute1];
    [imageView addSubview:textOfPassword];
    UIImageView *image2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_password"]];
    image2.frame = CGRectMake(10, 341, 30, 30);
    textOfPassword.leftView = image2;
    textOfPassword.leftViewMode = UITextFieldViewModeAlways;
    //忘记密码
    UIImageView *imageOfMiss = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ImageOfMiss"]];
    imageOfMiss.frame = CGRectMake(245, 400, 20, 20);
    [imageView addSubview:imageOfMiss];
    UIButton *buttonOfMiss = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonOfMiss.frame = CGRectMake(265, 400, 70, 20);
    [imageView addSubview:buttonOfMiss];
    [buttonOfMiss setTitle:@"忘记密码" forState:UIControlStateNormal];
    [buttonOfMiss setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [buttonOfMiss addTarget:self action:@selector(handleMiss:) forControlEvents:UIControlEventTouchUpInside];
    //登录按钮
    UIButton *buttonOfLogin = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonOfLogin.frame = CGRectMake(10, 460, 355, 40);
    buttonOfLogin.backgroundColor = [UIColor colorWithRed:0.18 green:0.8 blue:0.58 alpha:1];
    [imageView addSubview:buttonOfLogin];
    [buttonOfLogin setTitle:@"登录" forState:UIControlStateNormal];
    [buttonOfLogin setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    buttonOfLogin.titleLabel.font = [UIFont systemFontOfSize:18];
    [buttonOfLogin addTarget:self action:@selector(handleLogin:) forControlEvents:UIControlEventTouchUpInside];
    //注册拉钩
    UIView *viewOfSignIn = [[UIView alloc] initWithFrame:CGRectMake(10, 530, 350, 40)];
    viewOfSignIn.backgroundColor = [UIColor colorWithRed:0.18 green:0.8 blue:0.58 alpha:1];
    viewOfSignIn.alpha = 0.1;
    [imageView addSubview:viewOfSignIn];
    UIButton *buttonOfSignIn = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonOfSignIn.frame = CGRectMake(10, 530, 350, 40);
    [buttonOfSignIn setTitle:@"注册拉钩" forState:UIControlStateNormal];
    buttonOfSignIn.layer.masksToBounds = YES;
    buttonOfSignIn.layer.borderWidth = 1;
    buttonOfSignIn.layer.borderColor = [[UIColor colorWithRed:0.18 green:0.8 blue:0.58 alpha:1] CGColor];
    buttonOfSignIn.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    [buttonOfSignIn setTitleColor:[UIColor colorWithRed:0.2 green:0.8 blue:0.58 alpha:1] forState:UIControlStateNormal];
    [buttonOfSignIn addTarget:self action:@selector(handleSignIn:) forControlEvents:UIControlEventTouchUpInside];
    [imageView addSubview:buttonOfSignIn];
}
- (void)handleLogin:(UIButton *)button
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)handleMiss:(UIButton *)button
{
    ViewControllerOfMiss *miss = [ViewControllerOfMiss new];
    [self presentViewController:miss animated:YES completion:nil];
}
- (void)handleSignIn:(UIButton *)button
{
    ViewControllerSignIn *sign = [ViewControllerSignIn new];
    [self presentViewController:sign animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
